package com.yunshipei.core.common;

import android.content.Context;

import com.yunshipei.core.utils.FileSizeUtils;
import com.yunshipei.core.utils.SystemUtils;

import org.json.JSONArray;
import org.json.JSONObject;

public final class DeviceInfo {

    private Context context;

    public DeviceInfo(Context context) {
        this.context = context.getApplicationContext();
    }

    public String allInfo() {
        JSONObject pIJson = new JSONObject();
        try {
            pIJson.put("devicePlatform", SystemUtils.isPad(context) ? "Android Pad" : "Android");
            pIJson.put("deviceName", SystemUtils.getDevicesName());
            pIJson.put("appVersion", SystemUtils.getVersionName(context));
            pIJson.put("systemVersion", SystemUtils.getSystemVersion());
            pIJson.put("deviceId", SystemUtils.getDevicesID(context));
            pIJson.put("phoneNums", new JSONArray().put(SystemUtils.getPhoneNumber(context)));
            pIJson.put("IMSI", SystemUtils.getSubscriberId(context));
            pIJson.put("operator", SystemUtils.getMobileOperator(context));
            pIJson.put("isRoot", SystemUtils.isDeviceRooted());
            pIJson.put("total", FileSizeUtils.getTotalMemorySize(context));
            pIJson.put("used", FileSizeUtils.getAvailableMemory(context));
            pIJson.put("MAC", SystemUtils.getMacAddress(context));
            pIJson.put("deviceBrand", android.os.Build.MANUFACTURER);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return pIJson.toString();
    }

    public String getDevicesID() {
        return SystemUtils.getDevicesID(context);
    }
}
